<?php
	require_once 'Connect.class.php';
	require_once 'DanhMuc.class.php';
	/**
	* 
	*/
	class HocVi extends DanhMuc
	{

		private $vietTat;


		public function __construct()
		{
			# code...
		}		

		public function setVietTat($vt){
			$this->vietTat=$vt;
		}

		public function getVietTat(){
			return $this->vietTat;
		}


		public function getInfo($maHV){

			$conn= new Connect();

			$conn->Query("SELECT * FROM tbl_hoc_vi WHERE maHV='".$maHV."'; ");	

			while ($row=$conn->Fetch()) {	

				$this->ma=$row['maHV'];
				
				$this->ten=$row['tenHV'];

				$this->vietTat=$row['vietTat'];

			}
			// dong ket noi
			$conn->close();
		}

		public function checkNo($maHV){

			$rs=false;

			$conn= new Connect();

			$conn->Query("SELECT COUNT(maHV) as dem FROM tbl_hoc_vi WHERE maHV='".$maHV."'; ");	

			while ($row=$conn->Fetch()) {	
				if ($row['dem']==1){
					$rs=true;
				}
			}
			// dong ket noi
			$conn->close();
			return $rs;
		}

		public function capnhat(){

			$sql="UPDATE tbl_hoc_vi SET tenHV='".$this->ten."',vietTat='".$this->vietTat."' WHERE maHV='".$this->ma."' ";

			$conn=new Connect();

			$conn->Query($sql);

			$conn->close();
		}
		public function them(){
			$sql="INSERT INTO tbl_hoc_vi(maHV,tenHV,vietTat) values('".$this->ma."','".$this->ten."','".$this->vietTat."')";
			$conn=new Connect();
			
			$conn->Query($sql);
			
			$conn->close();
		}
		public function xoa(){
			$sql="DELETE FROM tbl_hoc_vi WHERE maHV='".$this->ma."'";
			$conn=new Connect();
			$conn->Query($sql);
			$conn->close();

		}
		public function ds(){
			$ds=array();

			$conn=new Connect();

			$sql="SELECT * FROM tbl_hoc_vi";

			$conn->Query($sql);

			$index=0;

			while ($row=$conn->Fetch()) {

				$hv= new HocVi();

				$hv->setMa($row['maHV']);

				$hv->setTen($row['tenHV']);

				$hv->setVietTat($row['vietTat']);				

				$ds[$index]=$hv;

				$index++;
			}
			$conn->close();

			return $ds;
		}
	}
?>